<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>足迹编辑</title> <%@ include file="/page/wx/include.jsp"%>
<script type="text/javascript" src="<%=basePath%>/statics/plugins/layer/layer.js"></script>
<script type="text/javascript">
    $(function() {
        $('.bjd_list1_con ul li i').click(function() {
            $(this).toggleClass('current');
        });
    });
</script>
<style>
.fl_nav1 {
    top: 0
}

.cart_bottom2 {
    bottom: 0;
}

.pp_box {
    top: 0.78rem;
}

.bjd_list1_con ul li {
    position: relative
}

.bjd_list1_con ul li i {
    position: absolute;
    cursor: pointer;
    left: 0.25rem;
    top: 50%;
    width: .36rem;
    height: .36rem;
    margin-top: -.18rem;
    background: url('<%=basePath%>/statics_wx/images/icon-q1.png') no-repeat;
    background-size: .35rem .35rem;
}

.bjd_list1_con ul li i.current {
    background: url('<%=basePath%>/statics_wx/images/icon-q2.png') no-repeat;
    background-size: .35rem .35rem
}

.bjd_list1_con ul li .box4 {
    margin-left: .82rem;
}
</style>
</head>
<body style="background: #f5f5f5">
	<c:set var="recordDate" value=""></c:set>
	<c:choose>
		<c:when test="${recordCount == 0 }">
			<div class="noresult">
				<p>
					<i><img src="<%=basePath%>/statics_wx/images/icon_zj.png" /></i> <span>您还没有 浏览过商品哦~</span>
				</p>
			</div>
		</c:when>
		<c:otherwise>
			<div class="headerfixed"></div>
			<div class="fl_nav1" style="top: 0px;">
				<strong>最近浏览${recordCount }个商品</strong> <b> <a href="<%=basePath%>/wx/browseRecord/toProductBrowseRecordPage">完成</a>
				</b>
			</div>
			
			<c:forEach items="${recordList }" var="record" varStatus="i">
				<c:set var="intNum" value="${fn:substringBefore(record.productPrice, '.') }"></c:set>
				<c:set var="smallNum" value="${fn:substringAfter(record.productPrice, '.') }"></c:set>
				<c:if test="${smallNum == '0000' }">
					<c:set var="smallNum" value="00"></c:set>
				</c:if>
				
				<c:choose>
					<c:when test="${record.browseDate eq today }">
						<c:if test="${record.browseDate != recordDate }">
							<c:set var="recordDate" value="${record.browseDate}"></c:set>
							<div class="hd12">
								<h3>今天</h3>
							</div>
						</c:if>
					</c:when>
					<c:when test="${record.browseDate eq recordDate }">
						
					</c:when>
					<c:otherwise>
						<c:set var="recordDate" value="${record.browseDate}"></c:set>
						<div class="hd12">
							<h3>${record.browseDate}</h3>
						</div>
					</c:otherwise>
				</c:choose>
				<div class="bjd_list1">
					<div class="bjd_list1_con">
						<ul>
							<li>
								<i title="${record.id}"></i>
								<div class="box4">
									<div class="pic">
										<img src="${imgRootURL }${record.productImg}${ossImgZoomWX}" onerror="this.src='<%=basePath%>/statics/images/default.jpg';"
											onclick="javascript: doProductDetail('${record.productId}');">
									</div>
									<div class="item-info">
										<h2 onclick="javascript: doProductDetail('${record.productId}');">
											<c:choose>
												<c:when test="${fn:length(record.productName) >= 50 }">
                                                    ${fn:substring(record.productName, 0, 50) }...
                                                </c:when>
												<c:otherwise>
                                                    ${record.productName}
                                                </c:otherwise>
											</c:choose>
										</h2>
										<h3 style="z-index: 90; background: white;">
											<strong>¥ <em>${intNum }.</em>${smallNum }
											</strong>
										</h3>
									</div>
								</div>
							</li>
							
						</ul>
					</div>
				</div>
			</c:forEach>
		</c:otherwise>
	</c:choose>
	<div class="footerfixed2"></div>
    <div class="cart_bottom2" style="z-index: 95;">
         <div class="cart_bottom2_con">
             <label><i id="allLi" onclick="javascript: doAllCheck();"></i><span>全选</span></label>
             <b><a href="#" onclick="javascript: doDelRecord();" class="btn3 a11">删除足迹</a>
             </b>
         </div>
     </div>
	<jsp:include page="../../wx_footer.jsp" />
<script type="text/javascript">

function doAllCheck() {
    $(".bjd_list1_con ul li i").removeClass('current');
    //$(".bjd_list1_con ul li i").toggleClass('current');
    $("#allLi").toggleClass('current');
    var className = $("#allLi").attr("class");
    $(".bjd_list1_con ul li i").addClass(className);
}

/**
 * 查看商品详情
 */
function doProductDetail(productId) {
    window.location.href = '<%=basePath%>/wx/product/detail?productId=' + productId;
}

/**
 * 删除足迹（批量）
 */
function doDelRecord() {
    var liArr = $("i.current");
    if(liArr && liArr.length > 0) {
        var idArrStr = '';
        for(var i = 0; i < liArr.length; i ++) {
            if(liArr[i].title) {
                idArrStr += liArr[i].title + ',';
            }
        }
        if(idArrStr) {
            $.ajax({
                type : "post",
                url : rootPath + '/wx/browseRecord/doDelRecord',
                data : {
                    idArrStr : idArrStr
                },
                async : false,
                datatype : "json",
                success : function(json) {
                    if (json.code == '1') {
                        layer.msg(json.msg,function() {
                            window.location.href = '<%=basePath%>/wx/browseRecord/toProductBrowseRecordEditPage';
                        },{time:2000});
                    } else {
                        layer.msg(json.msg,{time:3000});
                    }
                },
                error : function() {
                    layer.msg('暂时无法删除足迹',{time:1000});
                }
            });
        } else {
            layer.msg('请先选择商品',{time:1000});
        }
    } else {
        layer.msg('请先选择商品',{time:1000});
    }
}
</script>
</body>
</html>